﻿using System;
using System.Diagnostics;
using System.Windows.Forms;
using BlueDot.Mobile.Core;

namespace TurnOffWorkFlow
{
    internal static class Program
    {
        #region private

        private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            ShowException(e.ExceptionObject as Exception);
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [MTAThread]
        private static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

            var runtime = new MobileRuntime();
            runtime.RegisterApplication(typeof (MainApplication));
            runtime.Start();
        }

        private static void ShowException(Exception ex)
        {
            if (ex != null)
            {
                Trace.WriteLine("An Exception Has Occured: " + ex);
                MessageBox.Show(ex.ToString(), "An Exception Has Occured");
            }

            Application.Exit();
        }

        #endregion
    }
}